#include <torch/torch.h>
#include <iostream>
#include <stdint.h>

int main() {
	// torch Tensor test
	torch::Tensor tensor = torch::rand({3, 3});
	std::cout << "*** dump torch Tensor: " << std::endl;
	std::cout << tensor << std::endl;
	std::cout << std::endl;

	// rsqrt test
	torch::Tensor x = torch::tensor({{1.0, 4.0, 9.0, 16.0}});
	std::cout << "*** dump rsqrt for 1.0, 1.0, 1.0, 16.0: " << std::endl;
	torch::Tensor rsqrt_x = torch::rsqrt(x);
	std::cout << rsqrt_x << std::endl;
	std::cout << std::endl;

	// torch float test
	at::Half fp16 = 1.5;
	uint16_t fp16_bin = 0;
	memcpy(&fp16_bin, &fp16, sizeof(uint16_t));
	std::cout << "*** torch float test" << std::endl;
	std::cout << "fp16=" << fp16 << std::endl;
	printf("fp16_bin=0x%x\n", fp16_bin);
	std::cout << std::endl;

	return 0;
}
